import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/account/login'), hidden: true },

  { path: '/404', component: () => import('@/views/404'), hidden: true },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: '首页',
    hidden: true,
    children: [{
      name: '主页',
      path: 'dashboard',
      component: () => import('@/views/dashboard/index')
    }, {
      name: '修改密码',
      path: 'password',
      meta: { title: '修改密码', icon: '' },
      component: () => import('@/views/account/password'),
      hidden: true
    }]
  }, {
    path: '',
    component: Layout,
    redirect: '/app/list',
    name: '平台',
    meta: { title: '平台', icon: 'example' },
    children: [{
      path: 'app/list',
      name: '应用',
      component: () => import('@/views/app/list'),
      meta: { title: '应用', icon: 'table' }
    }, {
      path: 'staff/list',
      name: '职员',
      component: () => import('@/views/staff/list'),
      meta: { title: '职员', icon: 'user' }
    }, {
      path: 'app/add',
      name: '添加',
      component: () => import('@/views/app/add'),
      meta: { title: '添加', icon: 'form' }
    }, {
      path: 'app/edit',
      name: '编辑',
      component: () => import('@/views/app/edit'),
      meta: { title: '编辑', icon: 'form' }
    }, {
      path: 'app/show',
      name: '查看',
      component: () => import('@/views/app/show'),
      meta: { title: '查看', icon: 'form' }
    }]
  }, {
    path: '',
    component: Layout,
    name: '管理员',
    meta: { title: '管理员', icon: 'user' },
    redirect: '/admin/list',
    children: [{
      path: 'admin/list',
      name: '管理员列表',
      component: () => import('@/views/admin/list'),
      meta: { title: '列表', icon: 'table' }
    }, {
      path: 'admin/edit',
      name: '管理员编辑',
      component: () => import('@/views/admin/edit'),
      meta: { title: '编辑', icon: 'user' }
    }, {
      path: 'admin/add',
      name: '管理员添加',
      component: () => import('@/views/admin/add'),
      meta: { title: '添加', icon: 'form' }
    }]
  }, {
    path: '',
    component: Layout,
    name: '角色',
    meta: { title: '角色', icon: 'tree' },
    redirect: '/role/list',
    children: [{
      path: 'role/list',
      name: '角色列表',
      component: () => import('@/views/role/list'),
      meta: { title: '列表', icon: 'table' }
    }, {
      path: 'role/add',
      name: '角色添加',
      component: () => import('@/views/role/edit'),
      meta: { title: '添加', icon: 'form' }
    }, {
      path: 'role/edit',
      name: '角色编辑',
      component: () => import('@/views/role/edit'),
      meta: { title: '编辑', icon: 'form' }
    }]
  }, {
    path: '/log',
    component: Layout,
    name: '日志',
    meta: { title: '日志', icon: 'table' },
    redirect: '/log/login',
    children: [{
      path: 'login',
      name: '登录日志',
      component: () => import('@/views/log/list'),
      meta: { title: '登录日志', icon: '' }
    }, {
      path: 'admin',
      name: '后台日志',
      component: () => import('@/views/log/list'),
      meta: { title: '后台日志', icon: '' }
    }, {
      path: 'push',
      name: '推送',
      component: () => import('@/views/log/list'),
      meta: { title: '推送日志', icon: '' }
    }, {
      path: 'api',
      name: '接口',
      component: () => import('@/views/log/list'),
      meta: { title: '接口日志', icon: '' }
    }, {
      path: 'test',
      name: '测试',
      component: () => import('@/views/log/list'),
      meta: { title: '测试日志', icon: '' }
    }]
  },

  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
